/* 
 * @(#)BeanLocator.java 2013-5-21
 * Copyright (c) 2013 TianYu Technologies, Inc. All rights reserved.   
 * 
 * This software is the confidential and proprietary information of   
 * TianYu Technologies. You shall not disclose such Confidential Information   
 * and shall use it only in accordance with the terms of the agreements   
 * you entered into with TianYu Technologies.   
 *   
 */
package com.code.common.spring;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

/**
 * 
 * 提供getBean接口
 * 
 * @author 李鹏
 * @since 1.0
 * @version 2013-6-3 李鹏
 */
public class SpringBeanLocator implements BeanFactoryAware {

	protected static final Log logger = LogFactory.getLog(SpringBeanLocator.class);

	private static BeanFactory beanFactory = null;

	public void setBeanFactory(BeanFactory factory) throws BeansException {
		beanFactory = factory;
	}

	public static Object getBean(String beanName) {
		if (beanFactory != null) {
			return beanFactory.getBean(beanName);
		}
		return null;
	}
}